import { configureStore, createStore, ThunkAction, EnhancedStore, Action } from '@reduxjs/toolkit'
import home from 'views/home/homeSlice'
import classify from 'views/classify/classifySlice'

// 日志打印中间件
import logger from 'redux-logger'
// rtk - thunk中间件 如果想用其他中间件，怎么办？

export const store = configureStore({
  reducer: {
    home,
    classify,
  },
  // middleware: (getDefaultMiddleware) => [...getDefaultMiddleware(), logger],
  // middleware: (getDefaultMiddleware) => [...getDefaultMiddleware(), logger],
})

export type AppDispatch = typeof store.dispatch
export type RootState = ReturnType<typeof store.getState>
export type AppThunk<ReturnType = void> = ThunkAction<ReturnType, RootState, unknown, Action<string>>
